<%@page contentType="text/html;charset=utf-8" pageEncoding="UTF-8" %>
<%@page import="org.ipo.mm.web.util.ConstantManager, java.util.Collection, org.ipo.mm.web.util.security.SecurityManager, org.ipo.mm.web.util.pager.AbstractPager, java.util.Vector" %>
<%@taglib prefix="l" uri="http://struts.apache.org/tags-logic" %>
<%@taglib prefix="b" uri="http://struts.apache.org/tags-bean" %>
<%@taglib prefix="h" uri="http://struts.apache.org/tags-html"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<script type="text/javascript">
    
</script>

<script type="text/javascript">
<!--
function SetAllCheckBoxes(FormName, FieldName, CheckValue)
{
	if(!document.forms[FormName])
		return;
	var objCheckBoxes = document.forms[FormName].elements[FieldName];
	if(!objCheckBoxes)
		return;
	var countCheckBoxes = objCheckBoxes.length;
	if(!countCheckBoxes)
		objCheckBoxes.checked = CheckValue;
	else
		// set the check value for all check boxes
		for(var i = 0; i < countCheckBoxes; i++)
			objCheckBoxes[i].checked = CheckValue;
}
// -->
</script>

<h1><b:message key="menu_representatives_envelopes"/></h1>
<b:message key="repr_select_envelopes_mail_text"/>
<h:form action="/protected/print_mail">
    <div style="margin: 10px;">
        <h:submit property="operation" styleId="defaultButton"><b:message key="repr_print_envelopes_button"/></h:submit>
        <input type="button" onclick="SetAllCheckBoxes('BulkMailBean', 'selectedRepresentatives', true);" value="<b:message key='gen_select_all'/>">
        <input type="button" onclick="SetAllCheckBoxes('BulkMailBean', 'selectedRepresentatives', false);" value="<b:message key='gen_select_none'/>">
    </div>




    <div class="tabela">
        <table width="100%" border="0" >
            <tr>
                <th scope="col"><b:message key="repr_select_mail"/></th>
                <th scope="col"><b:message key="repr_name"/></th>
                <th scope="col"><b:message key="inst_address"/></th>
                <th scope="col"><b:message key="repr_function"/></th>
                <th scope="col"><b:message key="repr_inst"/></th>
                <th scope="col"><b:message key="gen_note"/></th>
            </tr>
            <l:empty name="REPRESENTATIVES">
                <tr class="red1">
                    <td colspan="8">
                        <div class="centeredinfo">
                            <img src="<%= request.getContextPath()%>/icons/info.png" align="top"/>
                            <b:message key="gen_no_search_results"/>

                        </div>
                    </td>
                </tr>

            </l:empty>
            <l:iterate id="repr" name="REPRESENTATIVES">
                <tr class="red1"><!--treba da ide red2 u svakom drugom-->
                    <td>
                        <h:multibox property="selectedRepresentatives">
                            <b:write name="repr" property="id"/>
                        </h:multibox>
                    </td>
                    <td>
                        <span style="font-weight: bolder">
                            <b:write name="repr" property="firstName"/>
                            <b:write name="repr" property="lastName"/>
                        </span>
                    </td>
                    <td>${repr.institution.address}, ${repr.institution.city.name}, ${repr.institution.city.zipCode}</td>
                    <td><b:write name="repr" property="function"/></td>
                    <td>${repr.institution.name}</td>
                    <td><b:write name="repr" property="note"/></td>

                </tr>
            </l:iterate>

            <tr>
                <th scope="col"><b:message key="repr_select_mail"/></th>
                <th scope="col"><b:message key="repr_name"/></th>
                <th scope="col"><b:message key="inst_address"/></th>
                <th scope="col"><b:message key="repr_function"/></th>
                <th scope="col"><b:message key="repr_inst"/></th>
                <th scope="col"><b:message key="gen_note"/></th>
            </tr>
        </table>
    </div><!--tabela-->


    <div style="margin: 10px;">
        <h:submit property="operation" styleId="defaultButton"><b:message key="repr_print_envelopes_button"/></h:submit>
        <input type="button" onclick="SetAllCheckBoxes('BulkMailBean', 'selectedRepresentatives', true);" value="<b:message key='gen_select_all'/>">
        <input type="button" onclick="SetAllCheckBoxes('BulkMailBean', 'selectedRepresentatives', false);" value="<b:message key='gen_select_none'/>">

    </div>
</h:form>
